package forward.Module.Modules.Misc;

import java.util.Timer;
import java.util.TimerTask;

import forward.Client;
import forward.api.EventHandler;
import forward.api.Events.World.EventPacketReceive;
import forward.Module.Module;
import forward.Module.ModuleType;
import forward.Module.Modules.Combat.Killaura;
import forward.UI.ClientNotification;
import forward.Util.ClientUtil;
import net.minecraft.network.play.server.S45PacketTitle;

public class AutoGG extends Module {

    public AutoGG() {
        super("AutoGG", new String[]{"TPAccept, autotp"}, ModuleType.Misc);
    }

    @EventHandler
    private void onPacket(EventPacketReceive ep) {
        if (ep.getPacket() instanceof S45PacketTitle) {
            S45PacketTitle packet = (S45PacketTitle) ep.getPacket();
            if (packet.getType().equals(S45PacketTitle.Type.TITLE)) {
                String text = packet.getMessage().getUnformattedText();
                if (text.equals("Again?")) {
                    new Timer().schedule(new TimerTask() {
                        @Override
                        public void run() {
                            mc.thePlayer.sendChatMessage("[forward]GG");
                            this.cancel();
                        }
                    }, 1340L);
                    Client.instance.getModuleManager().getModuleByClass(Killaura.class).setEnabled(false);
                    ClientUtil.sendClientMessage("(Auto)Killaura Disabled", ClientNotification.Type.ERROR);
                } else if (text.equals("�����ˣ�")
                        && Client.instance.getModuleManager().getModuleByClass(Killaura.class).isEnabled()) {
                    Client.instance.getModuleManager().getModuleByClass(Killaura.class).setEnabled(false);
                    ClientUtil.sendClientMessage("(Auto)Killaura Disabled", ClientNotification.Type.ERROR);
                }
            }
        }
    }
}
